<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<title><?php echo ($name); ?></title>
<script src="__APP__/statics/jquery-1.9.1.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="__APP__/statics/css/jNotify.jquery.css" />
<script type="text/javascript" src="__APP__/statics/jNotify.jquery.js"></script>
<style>
 body{font-family:"微软雅黑";font-size:12px;color:#666666;background-color:#F9F9F6}
 *{margin: 0;} 
 a{text-decoration:none}
 img{border:0px}
.cat{background-color:#F9F9F6;margin-left:10px;z-index:0;}
.cat_list:hover{background-color:#fff;}
.title{background:url("__APP__/statics/tbg.gif");font-weight:bold}

#save{text-align:center;border:0;width:100%;height:40px;background-color:#fff;position:fixed;left:0px;bottom:0px;z-index:999;border:1px solid #DFDFDF;background-color:#DFDFDF;padding:5px;height:20px}
</style>

<!--新货位添加-->
<div class="cat">
<form method="POST" action="__URL__/add">
	   <select size="1" name="pid">
		   <option value='0'>顶级货位</option>
<?php if(is_array($place_list)): $i = 0; $__LIST__ = $place_list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$place_list): $mod = ($i % 2 );++$i;?><option value="<?php echo ($place_list["place_id"]); ?>"><?php echo ($place_list["fullname"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
	  </select>

	货位：<input type="text" name="name" size="20">
	<input type="submit" value="添加货位" name="B1">
</form>
</div>


<!--货位列表-->
<div class="cat" style="margin-top:5px;">
<table bordercolor="#DDDFFF" border="1" width="100%" style="border-collapse: collapse" cellpadding="3">
	<tr height="17" align="center">
		<td class="title" width="40">排序</td>
		<td class="title" width="300">分类名称</td>

		<td class="title" width="40">修改</td>
		<td class="title" width="40">删除</td>

		<td class="title">　</td>
	</tr>
<?php if(is_array($place_list2)): $i = 0; $__LIST__ = $place_list2;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$place_list2): $mod = ($i % 2 );++$i;?><tr height="20" bgcolor="#F1F5FA" class="cat_list">
		<td width="40">
		<input type="text" name="place_id[]" value="<?php echo ($place_list2["place_id"]); ?>" style="display:none">
		<input name="sorting[]" size="10" type="text" value="<?php echo ($place_list2["sorting"]); ?>"></td>
<?php if($place_list2["parent"] == 0): ?><td width="300" style="font-weight:bold">[<?php echo ($place_list2["fullname"]); ?>]</td>
<?php else: ?>
        <td width="300"><?php echo ($place_list2["fullname"]); ?></td><?php endif; ?>

		<td width="40" align="center"><a href="__URL__/edit/?place=<?php echo ($place_list2["place_id"]); ?>"><img src="__APP__/statics/icons/member3.gif"></a></td>
		<td width="40" align="center"><a href="javascript:;" onclick="deletePlace(<?php echo ($place_list2["place_id"]); ?>)"><img alt="删除" src="__APP__/statics/icons/icon_delete.gif"></a></td>

		<td></td>
	</tr><?php endforeach; endif; else: echo "" ;endif; ?>
</table>
</div>
<br><br><br>
<div id="save"><input id="save_sort" type="button" value="保存排序"></div>

<script>
$(function(){
    $("#save_sort").click(function(){
              var place_id=[];
			  $("[name='place_id[]']").each(function(){
                     place_id.push($(this).val()); 
               }); 
			  var sorting=[];
			  $("[name='sorting[]']").each(function(){
                     sorting.push($(this).val()); 
               }); 
			   $.ajax({
			         type:"POST",
					 url:"__URL__/sorting",
					 dataType:"html",
					 data:{'place_id':place_id,'sort':sorting},
					 success:function(data){
					 }
			   })
			  location.reload();
	})
})

function deletePlace(t){
	if(confirm('你确认删除此模型吗？')) {
		$.get('__URL__/deletePlace',{'place_id':t},function(res){
			location.reload();
		})
	}
}
</script>